import axios from 'axios'
/* eslint-disable */

export default {
    host: window.location.host.indexOf('localhost') > -1 ? 'http://localhost:3000' : 'http://bigheadlyfa1.cloudapp.net:3000',
    getLog: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/log').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    getOrder: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/order').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    getAgenda: function(date) {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/agenda?date=' + date).then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    getPendingOrder: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/order/pending').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    getProfile: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/balance').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    startRobot: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/start').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    },
    stopRobot: function() {
        var self = this;
        return new Promise((fullfile, reject) => {
            axios.get(this.host + '/stop').then(response => {
                fullfile(response.data);
            }).catch(e => {
                reject(e);
            })
        });
    }
}